#include "VertexFormats.fx"
#include "Bluring.fx"

struct VSOut
{
	float4 pos : POSITION;
	float2 uv : TEXCOORD0;
	float4 color : COLOR;
};

texture tex : SPRITE_TEXTURE;
float4 tex_size : TEXTURE_SIZE;

sampler tex_sampler =
sampler_state
{
    Texture = <tex>;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
	AddressU = CLAMP;
	AddressV = CLAMP;
};

VSOut VS_BluredSpriteBatch(VertexPosUVColor input)
{
	VSOut output;
	output.pos = float4(input.pos, 1);
	output.uv = input.uv;
	output.color = input.color;
	return output;
}

float4 PS_BluredSpriteBatchH(VSOut input) : COLOR
{
    return gaussian7HBlur(tex_sampler, input.uv, tex_size.xy) * input.color *
	1.1;
}

float4 PS_BluredSpriteBatchV(VSOut input) : COLOR
{
	return gaussian7VBlur(tex_sampler, input.uv, tex_size.xy) * input.color * 
	1.1;
}

technique t0
{
	pass p0
	{
		VertexShader = compile vs_2_0 VS_BluredSpriteBatch();
		PixelShader = compile ps_2_0 PS_BluredSpriteBatchH();
		
		AlphaBlendEnable = true;
		SrcBlend = srcAlpha;
		DestBlend = invSrcAlpha;
	}
}

technique t1
{
	pass p0
	{
		VertexShader = compile vs_2_0 VS_BluredSpriteBatch();
		PixelShader = compile ps_2_0 PS_BluredSpriteBatchV();
		
		AlphaBlendEnable = true;
		SrcBlend = srcAlpha;
		DestBlend = invSrcAlpha;
	}
}
